<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active{
            color: red;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul>
            <!-- item:表示数组的每一项数据 -->
            <!-- index:表示数组的下标 -->
            <li v-for="(item,index) in movies" v-on:click="changeColor(item,index)" :class="{'active':flag===index}">
               {{index}} - {{item}}</li>
        </ul>
    </div>

    <script src="./vue.js"></script>
    <script>
        let app = new Vue({
            el: "#app",
            data: {
                movies: ["流浪地球","封神","人在囧途","泰囧"],
                flag:0
            },
            methods: {
                changeColor(item, index) {
                    this.flag=index;

                }
            }
        })
    </script>

</body>

</html>